import java.util.Scanner;

public class test2 {
    //递归求 1 + 2 + 3 + ... + 10
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数字n:");
        int n = sc.nextInt();
        int sum = getSum(n);
        System.out.println("结果为:"+sum);
    }
    public static int getSum(int n){
        if(n==1){
            return 1;
        }else {
            return n + getSum(n - 1);
        }
    }
}
